import { Component, OnInit,ViewChild } from '@angular/core';

@Component({
  selector: 'app-viewchild',
  templateUrl: './viewchild.component.html',
  styleUrls: ['./viewchild.component.css']
})
export class ViewchildComponent implements OnInit {

  @ViewChild('mybox') aaa:any
  @ViewChild('news') news:any
  constructor() { }

  ngOnInit(): void {
  
  }

  ngAfterViewInit(): void {
    //Called after ngAfterContentInit when the component's view has been initialized. Applies to components only.
    //Add 'implements AfterViewInit' to the class.
    console.log(this.aaa,'打印mybox')
    console.log(this.news,'打印news')
    // 调用子组件方法
    this.news.say()
  }
}
